﻿using Architecture.API.Application.TraceabilityCommand.PackagingMaterialsCommand;
using MediatR;
using Traceability.Domain.Service.PackagingMaterialsServices;
using Traceability.Domain.TraceabilityDto;

namespace Architecture.API.Application.TraceabilityCommandHandler.PackagingMaterialsCommandHandler
{
    /// <summary>
    /// 
    /// </summary>
    public class ShowPackagingMaterialsCommandHandler : IRequestHandler<ShowPackagingMaterialsCommand, List<PackagingMaterialsDto>>
    {
        /// <summary>
        /// 包材服务
        /// </summary>
        protected readonly IPackagingMaterialsService packagingMaterialsService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="packagingMaterialsService">包材服务</param>
        public ShowPackagingMaterialsCommandHandler(IPackagingMaterialsService packagingMaterialsService)
        {
            this.packagingMaterialsService = packagingMaterialsService;
        }

        public async Task<List<PackagingMaterialsDto>> Handle(ShowPackagingMaterialsCommand request, CancellationToken cancellationToken)
        {
            return await packagingMaterialsService.GetAllPackagingMaterials(request.shoppingId);
        }
    }
}
